$(function(){
	$("#publishBtn").click(publish);
});

function publish() {
	$("#publishModal").modal("hide");

	// 获取标题和内容
	var title = $("#recipient-name").val();
	var content = $("#message-text").val();
	// 发送异步请求(POST)
	$.post(
		CONTEXT_PATH + "/discuss/add",
		{"title":title,"content":content},
		function (data) {
			data = $.parseJSON(data);
			// 在提示框中显示返回信息
			$("#hintBody").text(data.msg);
			// 显示提示框
			$("#hintModal").modal("show");
			// 2秒后，自动隐藏提示框
			setTimeout(function(){
				$("#hintModal").modal("hide");
				// 刷新页面
				if (data.code == 0){
					window.location.reload();
				}
			}, 2000);
		}
	);
}
layui.use(['admin', 'layer','index'], function (exports) {
	var $ = layui.$;
	var admin = layui.admin;
	var layer = layui.layer;
	var index = layui.index;

	index = {
		bindEvent: function () {

		},
	}
	index.bindEvent(function () {
		// 签到
		$('#btnSign').click(function () {
			let userinfo = {};
			index.getUser(function (user) {
				userinfo = user;
			});
			console.log(userinfo);
			admin.req("api-points/pointsBusiness/signIn/".concat(userinfo.id), {}, function (res) {
				layer.msg(res.msg);
			}, "POST")
		});
	})
	exports('index', index);
});
